package repository

import (
	"apps/cqrs-example/internal/products/models"

	"github.com/google/uuid"
)

type InMemoryProductRepository struct {
}

var products []models.Product

func NewInMemoryProductRepository() *InMemoryProductRepository {
	return &InMemoryProductRepository{}
}

func (p *InMemoryProductRepository) CreateProduct(product models.Product) models.Product {
	products = append(products, product)
	return product
}

func (p *InMemoryProductRepository) GetProductById(uuid uuid.UUID) *models.Product {
	var product *models.Product
	for _, prod := range products {
		if prod.ProductID == uuid {
			product = &prod
			break
		}
	}
	return product
}
